feat: add merge commit version strategy - #5140
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18f6910930
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e34bfa475
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
4e34bfa to
f6b83bb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6b83bb5c1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
f6b83bb to
52598be
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52598be177
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
52598be to
1c8f29f
Compare
Walk first-parent history in ancestry order, resolve inherited increments from the merged branch source, and remove identical conditional test branches flagged by analysis.
Resolve reused branch names from the historical first-parent lineage, align source reset detection with tagged commit history, preserve merge-message ordering, and stop scanning at the latest target tag.
1c8f29f to
3f8211c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f8211c580
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8823790f7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5cee297f10
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Keep merged tags tied to post-tag work, reconstruct inherited branch configuration from the historical merge tip, and retain higher first-parent tag candidates across later target tags. Also enable the strategy for inherited main configurations without applying it to pull request branches, and document how target-branch work contributes to the effective increment.
|
|
Thank you very much for the PR. Actually, I need some time for the review. |
|
@fzlzjerry please rebase your branch into |



Description
Adds a configurable
MergeCommitversion strategy for GitFlow and GitHubFlow main branches withprevent-increment.of-merged-branchenabled.The strategy walks the target branch's first-parent history, uses the latest target-branch version tag as the reset boundary, and consolidates the highest effective increment across the post-tag history. Recognized merges contribute the source branch configuration, while direct target commits and merges whose source cannot be resolved contribute the target branch configuration. Repeated increments of the same kind do not accumulate. Source-branch commit-message increments and reset messages are honored, as is
prevent-increment.when-branch-merged; nested merge branch configurations do not replace the directly merged branch configuration.The strategy also preserves tags introduced by merged branches as alternative semantic versions and suppresses the regular tagged-commit candidate while active, so a larger target-branch increment cannot override the merged-branch increment. Each alternative tag tracks only increments encountered from the point where it enters the target history, allowing post-tag work to advance a higher merged tag without reapplying earlier target work. Historical source references are scored by graph distance before local-versus-remote preference is applied. The strategy is enabled in the GitFlow and GitHubFlow defaults and can be disabled through
strategies.Related Issue
Resolves #4433
Motivation and Context
Outside the mainline strategy, a no-fast-forward merge currently falls back to the target branch's configured increment. That makes a patch hotfix merged into a minor-increment main branch produce a minor version, and a minor feature merged into a patch-increment main branch produce a patch version. This change lets the merged branch determine the increment while retaining the existing tag-based version source and non-cumulative workflow semantics.
How Has This Been Tested?
Tested on Linux with .NET SDK 10.0.400:
when-branch-merged, nested merges, merged-branch tags and their post-tag increments (including a tag at the source tip with no later work), unrelated histories, inherited source-branch increments (including ignored commits, reused local names, valid remote refs, sources that later absorb the topic, and retained branches that later absorb the target), inherited main-branch configurations, target commits before and after recognized merges, unrecognized later merges with tags, older higher target tags behind later lower tags, merge-message ordering, and timestamp-skewed tags and first-parent traversal.dotnet build ./src/GitVersion.slnx --configuration Release --no-restore --verbosity minimal— succeeded with 0 warnings and 0 errors.dotnet test --solution ./src/GitVersion.slnx --configuration Release --no-build --output Normal— 37,238 succeeded, 0 failed.dotnet format ./src/GitVersion.slnx --verify-no-changes --no-restore --verbosity minimal— succeeded.Screenshots (if appropriate):
N/A
Checklist: